<template>
  <div class="index1">
    <!-- 页面主体 -->
    <router-view></router-view>
    <!-- 页面底部导航 start-->
    <mt-tabbar v-model="selected" fixed>
      <mt-tab-item id="index">
        <span
          v-if="selected !== `index`"
          class="icon-bg icbg1"
          slot="icon"
        ></span>
        <span v-else class="icon-bg active-ic1" slot="icon"></span>
        首页
      </mt-tab-item>
      <mt-tab-item id="renew">
        <span
          v-if="selected !== `renew`"
          class="icon-bg icbg2"
          slot="icon"
        ></span>
        <span v-else class="icon-bg active-ic2" slot="icon"></span>
        换新机
      </mt-tab-item>
      <mt-tab-item id="tuijian">
        <span
          v-if="selected !== `tuijian`"
          class="icon-bg icbg3"
          slot="icon"
        ></span>
        <span v-else class="icon-bg active-ic3" slot="icon"></span>
        回收站
      </mt-tab-item>
      <mt-tab-item id="aboutme">
        <span
          v-if="selected !== `aboutme`"
          class="icon-bg icbg4"
          slot="icon"
        ></span>
        <span v-else class="icon-bg active-ic4" slot="icon"></span>
        我的
      </mt-tab-item>
    </mt-tabbar>
    <!-- 页面底部导航 end-->
  </div>
</template>
<style lang="scss">
.index1 {
  // 页面底部导航栏
  .icon-bg {
    display: flex;
    width: 28px;
    height: 28px;
    background: url("/img/index/20200413104656_7617.png") no-repeat;
    background-size: 25rem;
  }
  .countdown-price {
    padding: 5px 20px 5px 0;
    margin-right: 15px;
    border-right: 1px dashed #000;
  }
  .countdown .countdown-img {
    width: 50px;
    height: 50px;
    margin-left: 30px;
    background: url("/img/index/20200714194403_6296.png");
    background-size: contain;
  }
  .icbg1 {
    background-position: 0px 0;
  }
  .icbg2 {
    background-position: -122px 0;
  }
  .icbg3 {
    background-position: -254px 0;
  }
  .icbg4 {
    background-position: -376px 0;
  }
  .active-ic1 {
    background-position: 0px -40px;
  }
  .active-ic2 {
    background-position: -122px -40px;
  }
  .active-ic3 {
    background-position: -254px -40px;
  }
  .active-ic4 {
    background-position: -376px -40px;
  }
}
.mint-tabbar > .mint-tab-item.is-selected {
  color: #f74444 !important;
}
.mint-navbar .mint-tab-item-label {
  font-size: 16px;
}
.mint-navbar {
  margin-top: 20px;
}
.mint-navbar .mint-tab-item.is-selected {
  position: relative;
  border-bottom: 0px solid #f74444 !important;
  color: #000 !important;
  font-weight: 700;
}
.mint-navbar .mint-tab-item {
  padding: 0 !important;
}
.mint-navbar .mint-tab-item.is-selected ::before {
  display: block;
  content: "";
  width: 18px;
  height: 0.17067rem;
  background: #f74444;
  border-radius: 0.17067rem;
  position: absolute;
  left: 50%;
  margin-left: -9px;
  bottom: 0px;
  -webkit-transition: left 1s;
  -o-transition: left 1s;
  transition: left 1s;
}
</style>
<script>
export default {
  data() {
    return {
      selected: "index",
      // 控制广告的隐藏
      adclose: true,
      // 被选中的导航栏,默认选中1
      selectednavitem: "1",
      // 一级类目
      first_type: [],
    };
  },
  methods: {
    // 关闭广告
    close() {
      this.adclose = false;
    },
  },
  mounted() {
    var selected = window.sessionStorage.getItem("selected");
    this.selected = selected;
  },
  watch: {
    // 底部导航
    selected(newVal) {
      // 当选择的selected发生改变时
      // 每当底部导航栏改变，就将selected存入到sessionStorage中，用来保存状态
      sessionStorage.setItem("selected", newVal);
      if (newVal == "index") {
        this.$router.push("/index");
      } else if (newVal == "renew") {
        this.$router.push("/renewindex");
      } else if (newVal == "tuijian") {
        this.$router.push("/tuijian");
      } else if (newVal == "aboutme") {
        this.$router.push("/aboutme");
      }
    },
  },
};
</script>

